package cn.im.qywx.wx.msg;

import cn.im.qywx.model.ImWxUserInfo;
import cn.im.qywx.wx.Message;
import cn.im.qywx.wx.component.Component;
import cn.im.qywx.wx.component.ComponentType;
import lombok.extern.slf4j.Slf4j;
import org.thymeleaf.util.StringUtils;

/**
 * @Description: 主模式下点击
 */
@Slf4j
public class MainClick extends Message {

	@Override
	public void execute(ImWxUserInfo userInfo) {
		String pubStr;
		ComponentType componentType;
		Component component;

		pubStr = userInfo.getQueueInfo().getWxXml().getEventKey();// 获取用户点击菜单的ID
		if(!StringUtils.isEmpty(pubStr)){
			pubStr = pubStr.toLowerCase();
			log.info("pubStr="+pubStr);
		}

		if ("click_menu_wakeon".equals(pubStr)) {//远程开机
			componentType = ComponentType.WakeOn;
		}else if("click_menu_ping".equals(pubStr)){//ping
			componentType = ComponentType.Ping;
		} else {// 主导航
				componentType = ComponentType.MainMenu;

			}

			component = Component.componentSelector(componentType);
			component.execute(userInfo);

		
	}

	
}
